package JZ;

/**
 * @Classname JZ28
 * @Description // https://leetcode-cn.com/problems/dui-cheng-de-er-cha-shu-lcof/ 树  一次ac
 * @Date 2021/4/21 14:41
 * @Created by yin
 */
public class JZ28 {
    public boolean isSymmetric(TreeNode root) {
        if(root==null) return true;
        return dfs(root.left,root.right);
    }
    public boolean dfs(TreeNode left,TreeNode right){
        if(left==null && right==null) return true;
        if(left==null ) return  false;
        if(right==null)  return false;
        if(left.val!= right.val){
            return false;
        }else{
            return dfs(left.left,right.right)&&dfs(left.right,right.left);
        }
    }
}
